package com.udp.nml.example;

public enum PacketType 
{
	BLANK, UNIT_ID , ERROR, REG_DATA, GOT_REG;
	
	public static PacketType getType(byte packetType)
	{
		switch (packetType)
		{
			case 1: return UNIT_ID;
			case 2: return ERROR;
			case 3: return REG_DATA;
			case 4: return GOT_REG;
		}
		
		return UNIT_ID;
	}
	
	public byte getByteValue()
	{
		byte byteValue = 0;
		
		if (this.equals(UNIT_ID))
		{
			byteValue = 1;
		}
		else if (this.equals(ERROR))
		{
			byteValue = 2;
		}
		else if (this.equals(REG_DATA))
		{
			byteValue = 3;
		}
		else if (this.equals(GOT_REG))
		{
			byteValue = 4;
		}
		
		return byteValue;
	}
}